import axios from 'axios'

export default function http(options) {
  return new Promise((resolve, reject) => {
    // https://github.com/mzabriskie/axios

    //创建一个axios实例
    const instance = axios.create({
      //设置默认根地址
      baseURL: "http://127.0.0.1",
      //设置请求超时设置
      timeout: 2000,
      //设置请求时的header
      headers: {
        'Github-url': 'https://github.com/zzmhot/vue-admin',
        'X-Powered-By': 'zzmhot'
      }
    })
    //请求处理
    instance(options)
      .then((data) => {
        //请求成功时,根据业务判断状态
        resolve(data);
      })
  })
}
